@extends('layouts.default') @section('main')
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="{{url('actprize/index')}}" class="tip-bottom">奖品管理</a>
                <a href="#" class="current">编辑奖品</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span9">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>编辑奖品</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('actprize/edit')}}" method="post" id="adForm" class="form-horizontal">
                                <div class="control-group">
                                    <label class="control-label">奖品id :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="id" value="{{$list->id}}" readonly placeholder="奖品名称" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">奖品名称 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="name" value="{{$list->name}}" placeholder="奖品名称" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">奖品内容 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="content" value="{{$list->content}}" placeholder="奖品内容" />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">奖品图片 :</label>
                                    <div class="controls">
                                        <input type="hidden" class="span11" name="image"
                                               placeholder="直通车图片" value="{{$list->image}}" />
                                        <img src="{{getImage($list->image)}}" width="120px" name="image" height="120px"/>
                                        <a href="javascript:void(0);" id="uploadWxphotoBtn"  onclick="javascript:openBrowse('uploadWxphotoBtn','uploadWxphoto');">点击上传(图片大小不小于h:624像素×w:1652像素)</a>
                                        <input type="file" id="uploadWxphoto" style="display:none" name="myfile" size="10" onchange="fileUpload('uploadWxphoto','image')"/>
                                    </div>
                                </div>
                                <div class="control-group ">
                                    <label class="control-label">奖品类型 :</label>
                                    <div class="controls ">
                                        <select  name="type" class=" span11" >
                                            <option value="">请选择</option>
                                            <option value="1"  @if($list->type==1) selected="selected" @endif>一等奖</option>
                                            <option value="2" @if($list->type==2) selected="selected" @endif>二等奖</option>
                                            <option value="3" @if($list->type==3) selected="selected" @endif>三等奖</option>
                                            <option value="4" @if($list->type==4) selected="selected" @endif>普通奖</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">概率（默认为1） :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="chances" value="{{$list->chances}}" placeholder="概率（默认为1）" />
                                    </div>
                                </div>

                                <div class="control-group ">
                                    <label class="control-label">所属的活动 :</label>
                                    <div class="controls ">
                                        <select  name="act_id" class=" span11" >
                                            <option value="">请选择</option>
                                            @foreach($acts as $k)
                                                <option value="{{$k->id}}" @if(isset($list->act) && $list->act->id==$k->id) selected @endif>{{$k->title}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">数量 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="num"  placeholder="数量" @if(isset($list->setting)) value="{{$list->setting->num}}" @endif />
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">排序 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="sort"  placeholder="排序" @if(isset($list->sort)) value="{{$list->sort}}" @endif />
                                    </div>
                                </div>
                                <input type="hidden" class="span11" name="formType" value="edit" />
                                <div class="form-actions">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">编辑</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $("#doSave").click(function(){
            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });
    </script>
@stop
